const axios = require('axios');
const MockAdapter = require('axios-mock-adapter');
const normalAxios = axios.create();
const mockAxios = axios.create();
import url_config from "./config";
import reqTools from "../utils/reqTools";

// mock 数据
var mock = new MockAdapter(mockAxios);

mock.onGet('/queryAll').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/api/advExam',
    config).then((res) => {
      resolve([200, res.data]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });

});

mock.onDelete('/deleteAdvExam').reply((config) => {
  return new Promise(function(resolve, reject) {
    const ids= config.ids;
    reqTools.delete('/api/advExam/'+ids).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

mock.onPut('/updateAdvExam').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.put('/api/advExam/deal',config.data,
     ).then((res) => {
      resolve([200, res ]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});


export default mockAxios;
